import type { App, Plugin } from 'vue'
import SvgIcon from '@/components/SvgIcon/index.vue'
import Pagination from '@/components/Pagination/index.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const allGlobalComponents = {
  SvgIcon,
  Pagination,
}

const ComponentsPlugin: Plugin = {
  //自定义组件全局插件
  install(app: App) {
    for (const key in allGlobalComponents) {
      app.component(key, allGlobalComponents[key as keyof typeof allGlobalComponents])
    }
    //注册element-plus图标为全局组件
    console.log(ElementPlusIconsVue)

    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  },
}

export default ComponentsPlugin
